<?php

/*验证码类*/
namespace app\index\controller;
use think\captcha\Captcha;
use think\Controller;
use think\facade\Request;


class Code extends Controller
{

    /*显示code*/
    public function showCode($timestamp){
        $config = [
            /*字体大小*/
            'fontSize' => 30,
            /*验证码位数*/
            'length'   => 4,
            /*验证码杂点*/
            'useNoise' => true,
            /*字体选择*/
            'fontttf'  => '5.ttf',
            /*使用背景*/
            'useImgBg' =>  true,
            /*支持中文*/
            'useZh'    => false
        ];
        $captcha = new Captcha($config);
        return $captcha->entry();
    }
    /*验证code*/
    public function checkCode(){
        $captcha = new Captcha();
        return $captcha->check(Request::post('code'));
    }
}